@echo off
setlocal

REM Build AiTalkManager.exe for Windows using PyInstaller
REM Entry: gui_multi_device.py

REM Ensure we run from the script directory
cd /d %~dp0

REM Optional: activate venv if exists
if exist .venv\Scripts\activate.bat (
  call .venv\Scripts\activate.bat
)

REM Install PyInstaller if missing
pyinstaller --version >nul 2>&1
if errorlevel 1 (
  echo Installing PyInstaller...
  pip install -q pyinstaller
)

REM Clean previous build artifacts
if exist build rmdir /s /q build
if exist dist rmdir /s /q dist
if exist AiTalkManager.spec del /f /q AiTalkManager.spec

set NAME=AiTalkManager
set ENTRY=gui_multi_device.py

REM Build single-file exe without console window
pyinstaller ^
  --noconsole ^
  --onefile ^
  --name %NAME% ^
  --add-data "settings.py;." ^
  --add-data "doubao;doubao" ^
  --add-data "1.ico;." ^
  --icon "1.ico" ^
  --noupx ^
  %ENTRY%

if errorlevel 1 (
  echo Build failed.
  exit /b 1
)

echo.
echo Build succeeded.
echo Output: dist\%NAME%.exe

endlocal

